
--[[
游戏登录界面，提供开始按钮，logo，简要设置按钮
 ]]
local MainScene = class("MainScene", cc.load("mvc").ViewBase)

function MainScene:onCreate()
    self:addChild(cc.LayerColor:create(ColorCfg.white), 0)

    local startButton = ccui.Button:create("start.png", "start.png", "start.png")
    startButton:setPosition(display.cx, display.cy)
    startButton:setEnabled(true)
    startButton:setScale(1.5)
    startButton:addTouchEventListener(function(sender, eventType)
        print("startButton click")
        if eventType == 0 then
            sender:setScale(1.6)
        elseif eventType == 2 then
            self:getApp():enterScene("GameScene")
            sender:setScale(5)
        elseif eventType == 3 then
            sender:setScale(5)
        end
    end)
    self:addChild(startButton, 10)


    local startLabel = cc.Label:create()
    startLabel:setTextColor(ColorCfg.orange)
    startLabel:setString("消灭星星")
    startLabel:setSystemFontSize(150)
    startLabel:setPosition(display.cx, display.height*0.8)
    self:addChild(startLabel, 10)
    cc.SimpleAudioEngine:getInstance():preloadEffect("pop_star.mp3")

    --最高分
    local highScore = cc.UserDefault:getInstance():getIntegerForKey("highScore", 0)
    print("highScore", highScore)
    if highScore > 3000 then
        -- 不到3000分的，认为玩家还不会玩，就不展示最高分了，不然展示的信息太多
        local highScoreLabel = cc.Label:create()
        highScoreLabel:setTextColor(ColorCfg.orange)
        highScoreLabel:setString("最高分：".. highScore)
        highScoreLabel:setSystemFontSize(80)
        highScoreLabel:setPosition(display.cx, 20)
        highScoreLabel:setAnchorPoint(0.5, 0)
        self:addChild(highScoreLabel, 10)
    end
end

return MainScene
